The pseudo variable n✓n✓n✓ni✓i✓i✓il✓l✓l✓l is an instance (usually the
only instance) of the class U✓U✓U✓Un✓n✓n✓nd✓d✓d✓de✓e✓e✓ef✓f✓f✓fi✓i✓i✓in✓n✓n✓ne✓e✓e✓ed✓d✓d✓dO✓O✓O✓Ob✓b✓b✓bj✓j✓j✓je✓e✓e✓ec✓c✓c✓ct✓t✓t✓t. n✓n✓n✓ni✓i✓i✓il✓l✓l✓l is used to
represent undefined values, and is also typically returned
in error situations. n✓n✓n✓ni✓i✓i✓il✓l✓l✓l is also used as a terminator in
sequences, as for example in response to the message _✓n_✓e_✓x_✓t
when there are no further elements in a sequence.
_✓R_✓e_✓s_✓p_✓o_✓n_✓d_✓s _✓t_✓o
_✓r isNil Overrides method found in Object. Return
true.
_✓r notNil Overrides method found in Object. Return
false.
_✓r printString Return 'nil'.
_✓E_✓x_✓a_✓m_✓p_✓l_✓e_✓s
Printed result
nil isNil True
Object
S✓S✓S✓Sy✓y✓y✓ym✓m✓m✓mb✓b✓b✓bo✓o✓o✓ol✓l✓l✓l
Instances of the class S✓S✓S✓Sy✓y✓y✓ym✓m✓m✓mb✓b✓b✓bo✓o✓o✓ol✓l✓l✓l are created either by
their literal representation, which is a pound sign followed
by a string of nonspace characters (for example #aSymbol ),
or by the message _✓a_✓s_✓S_✓y_✓m_✓b_✓o_✓l being passed to an object. Sym-
bols cannot be created using _✓n_✓e_✓w. Symbols are guaranteed to
have unique representations; that is, two symbols represent-
ing the same characters will always test equal to each
other. Inside of literal arrays, the leading pound signs on
symbols can be eliminated, for example: #(these are sym-
bols).
_✓R_✓e_✓s_✓p_✓o_✓n_✓d_✓s _✓t_✓o
_✓r == Return true if the two symbols represent the
same characters, false otherwise.
_✓r asString Return a String representation of the symbol
without the leading pound sign.
_✓r printString Return a String representation of the symbol,
including the leading pound sign.
_✓E_✓x_✓a_✓m_✓p_✓l_✓e_✓s
Printed result
#abc == #abc True
#abc == #ABC False
#abc ~~ #ABC True
#abc printString #abc
'abc' asSymbol #abc
Object
B✓B✓B✓Bo✓o✓o✓oo✓o✓o✓ol✓l✓l✓le✓e✓e✓ea✓a✓a✓an✓n✓n✓n
The class B✓B✓B✓Bo✓o✓o✓oo✓o✓o✓ol✓l✓l✓le✓e✓e✓ea✓a✓a✓an✓n✓n✓n provides protocol for manipulating
true and false values. The pseudo variables t✓t✓t✓tr✓r✓r✓ru✓u✓u✓ue✓e✓e✓e and f✓f✓f✓fa✓a✓a✓al✓l✓l✓ls✓s✓s✓se✓e✓e✓e
are instances of the subclasses of B✓B✓B✓Bo✓o✓o✓oo✓o✓o✓ol✓l✓l✓le✓e✓e✓ea✓a✓a✓an✓n✓n✓n; T✓T✓T✓Tr✓r✓r✓ru✓u✓u✓ue✓e✓e✓e and F✓F✓F✓Fa✓a✓a✓al✓l✓l✓ls✓s✓s✓se✓e✓e✓e,
respectively. The subclasses T✓T✓T✓Tr✓r✓r✓ru✓u✓u✓ue✓e✓e✓e and F✓F✓F✓Fa✓a✓a✓al✓l✓l✓ls✓s✓s✓se✓e✓e✓e, in combination
with blocks, are used to implement conditional control
structures. Note, however, that the bytecodes may optimize
conditional tests by generating code in-line, rather than
using message passing. Note that bit-wise boolean opera-
tions are provided by class I✓I✓I✓In✓n✓n✓nt✓t✓t✓te✓e✓e✓eg✓g✓g✓ge✓e✓e✓er✓r✓r✓r.
_✓R_✓e_✓s_✓p_✓o_✓n_✓d_✓s _✓T_✓o
& The argument must be a boolean. Return the
logical conjunction (and) of the two values.
| The argument must be a boolean. Return the
logical disjunction (or) of the two values.
and: The argument must be a block. Return the
logical conjunction (and) of the two values.
If the receiver is false the second argument
is not used, otherwise the result is the
value yielded in evaluating the argument
block.
or: The argument must be a block. Return the
logical disjunction (or) of the two values.
If the receiver is true the second argument
is not used, otherwise the result is the
value yielded in evaluating the argument
block.
eqv: The argument must be a boolean. Return the
logical equivalence (eqv) of the two values.
xor: The argument must be a boolean. Return the
logical exclusive or (xor) of the two values.
_✓E_✓x_✓a_✓m_✓p_✓l_✓e_✓s
Printed result
(1 > 3) & (2 < 4) False
(1 > 3) | (2 < 4) True
(1 > 3) and: [2 < 4] False
Object
Boolean
T✓T✓T✓Tr✓r✓r✓ru✓u✓u✓ue✓e✓e✓e
The pseudo variable t✓t✓t✓tr✓r✓r✓ru✓u✓u✓ue✓e✓e✓e is an instance (usually the
only instance) of the class T✓T✓T✓Tr✓r✓r✓ru✓u✓u✓ue✓e✓e✓e.
_✓R_✓e_✓s_✓p_✓o_✓n_✓d_✓s _✓T_✓o
ifTrue: Return the result of evaluating the argument
block.
ifFalse: Return n✓n✓n✓ni✓i✓i✓il✓l✓l✓l.
ifTrue:ifFalse:
Return the result of evaluating the first
argument block.
ifFalse:ifTrue:
Return the result of evaluating the second
argument block.
not Return f✓f✓f✓fa✓a✓a✓al✓l✓l✓ls✓s✓s✓se✓e✓e✓e.
_✓E_✓x_✓a_✓m_✓p_✓l_✓e_✓s
Printed result
(3 < 5) not False
(3 < 5) ifTrue: [17] 17
Object
Boolean
F✓F✓F✓Fa✓a✓a✓al✓l✓l✓ls✓s✓s✓se✓e✓e✓e
The pseudo variable f✓f✓f✓fa✓a✓a✓al✓l✓l✓ls✓s✓s✓se✓e✓e✓e is an instance (usually the
only instance) of the class F✓F✓F✓Fa✓a✓a✓al✓l✓l✓ls✓s✓s✓se✓e✓e✓e.
ifTrue: Return n✓n✓n✓ni✓i✓i✓il✓l✓l✓l.
ifFalse: Return the result of evaluating the argument
The class C✓C✓C✓Co✓o✓o✓ol✓l✓l✓ll✓l✓l✓le✓e✓e✓ec✓c✓c✓ct✓t✓t✓ti✓i✓i✓io✓o✓o✓on✓n✓n✓n provides protocol for groups of
objects, such as A✓A✓A✓Ar✓r✓r✓rr✓r✓r✓ra✓a✓a✓ay✓y✓y✓ys or S✓S✓S✓Se✓e✓e✓et✓t✓t✓ts. The different forms of col-
lections are distinguished by several characteristics, among
them whether the size of the collection is fixed or
unbounded, the presence or absence of an ordering, and their
insertion or access method. For example, an A✓A✓A✓Ar✓r✓r✓rr✓r✓r✓ra✓a✓a✓ay✓y✓y✓y is a col-
lection with a fixed size and ordering, indexed by integer
keys. A D✓D✓D✓Di✓i✓i✓ic✓c✓c✓ct✓t✓t✓ti✓i✓i✓io✓o✓o✓on✓n✓n✓na✓a✓a✓ar✓r✓r✓ry✓y✓y✓y, on the other hand, has no fixed size or
ordering, and can be indexed by arbitrary elements.
Nevertheless, A✓A✓A✓Ar✓r✓r✓rr✓r✓r✓ra✓a✓a✓ay✓y✓y✓ys✓s✓s✓s and D✓D✓D✓Di✓i✓i✓ic✓c✓c✓ct✓t✓t✓ti✓i✓i✓io✓o✓o✓on✓n✓n✓na✓a✓a✓ar✓r✓r✓ry✓y✓y✓ys✓s✓s✓s share many features in
common, such as their access method (_✓a_✓t: and _✓a_✓t:_✓p_✓u_✓t:), and
the ability to respond to _✓c_✓o_✓l_✓l_✓e_✓c_✓t:, _✓s_✓e_✓l_✓e_✓c_✓t:, and many other
messages.
The table below lists some of the characteristics of
The class K✓K✓K✓Ke✓e✓e✓ey✓y✓y✓ye✓e✓e✓ed✓d✓d✓dC✓C✓C✓Co✓o✓o✓ol✓l✓l✓ll✓l✓l✓le✓e✓e✓ec✓c✓c✓ct✓t✓t✓ti✓i✓i✓io✓o✓o✓on✓n✓n✓n provides protocol for collec-
tions with keys, such as D✓D✓D✓Di✓i✓i✓ic✓c✓c✓ct✓t✓t✓ti✓i✓i✓io✓o✓o✓on✓n✓n✓na✓a✓a✓ar✓r✓r✓ry✓y✓y✓ys✓s✓s✓s and A✓A✓A✓Ar✓r✓r✓rr✓r✓r✓ra✓a✓a✓ay✓y✓y✓ys✓s✓s✓s. Since each
entry in the collection has both a key and value, the method
_✓a_✓d_✓d: is no longer appropriate. Instead, the method _✓a_✓t:_✓p_✓u_✓t:,
which provides both a key and a value, must be used.
_✓R_✓e_✓s_✓p_✓o_✓n_✓d_✓s _✓t_✓o
asDictionary Return a new collection of type D✓D✓D✓Di✓i✓i✓ic✓c✓c✓ct✓t✓t✓ti✓i✓i✓io✓o✓o✓on✓n✓n✓na✓a✓a✓ar✓r✓r✓ry✓y✓y✓y
containing the elements from the receiver
collection.
at: Return the item in the receiver collection
whose key matches the argument. Produces and
error message, and returns nil, if no item is
currently in the receiver collection under
the given key.
at:ifAbsent: Return the element stored in the dictionary
under the key given by the first argument.
Return the result of evaluating the second
argument if no such element exists.
atAll:put: The first argument must be a collection con-
taining keys valid for the receiver. At each
location given by a key in the first argument
place the second argument.
binaryDo: The argument must be a two argument block.
This message is similar to _✓d_✓o:, however both
the key and the element value are passed as
argument to the block.
includesKey: Return true if the indicated key is valid for
the receiver collection.
indexOf: Return the key value of the first element in
the receiver collection matching the argu-
ment. Produces an error message if no such
element exists. Note that, as with the mes-
sage _✓d_✓e_✓t_✓e_✓c_✓t:, in unordered collections the
first element may not be related in any way
to the order in which elements were placed
into the collection, but is rather implemen-
tation dependent.
indexOf:ifAbsent:
Return the key value of the first element in
the receiver collection matching the argu-
ment. Return the result of evaluating the
class K✓K✓K✓Ke✓e✓e✓ey✓y✓y✓ye✓e✓e✓ed✓d✓d✓dC✓C✓C✓Co✓o✓o✓ol✓l✓l✓ll✓l✓l✓le✓e✓e✓ec✓c✓c✓ct✓t✓t✓ti✓i✓i✓io✓o✓o✓on✓n✓n✓n (continued)
second argument if no such element exists.
keys Return a Set containing the keys for the
receiver collection.
keysDo: The argument must be a one argument block.
Similar to _✓d_✓o:, except that the values passed
to the block are the keys of the receiver
collection.
keysSelect: Similar to _✓s_✓e_✓l_✓e_✓c_✓t, except that the selection
is made on the basis of keys instead of
values.
removeKey: Remove the object with the given key from the
receiver collection. Print an error message,
and return n✓n✓n✓ni✓i✓i✓il✓l✓l✓l, if no such object exists.
Return the value of the deleted item.
removeKey:ifAbsent:
Remove the object with the given key from the
receiver collection. Return the result of
evaluating the second argument if no such
object exists.
values Return a Bag containing the values from the
The class S✓S✓S✓Se✓e✓e✓eq✓q✓q✓qu✓u✓u✓ue✓e✓e✓en✓n✓n✓nc✓c✓c✓ce✓e✓e✓ea✓a✓a✓ab✓b✓b✓bl✓l✓l✓le✓e✓e✓eC✓C✓C✓Co✓o✓o✓ol✓l✓l✓ll✓l✓l✓le✓e✓e✓ec✓c✓c✓ct✓t✓t✓ti✓i✓i✓io✓o✓o✓on✓n✓n✓n contains protocol for
collections that have a definite sequential ordering and are
indexed by integer keys. Since there is a fixed order for
elements, it is possible to refer to the last element in a
copyFrom:to: Return a new collection, like the receiver,
containing the designated subportion of the
receiver collection.
copyWith: Return a new collection, like the receiver,
with the argument added to the end.
copyWithout: Return a new collection, like the receiver,
with all occurrences of the argument removed.
equals:startingAt:
The first argument must be a S✓S✓S✓Se✓e✓e✓eq✓q✓q✓qu✓u✓u✓ue✓e✓e✓en✓n✓n✓nc✓c✓c✓ce✓e✓e✓ea✓a✓a✓ab✓b✓b✓bl✓l✓l✓le✓e✓e✓eC✓C✓C✓Co✓o✓o✓ol✓l✓l✓l-✓-✓-✓-
l✓l✓l✓le✓e✓e✓ec✓c✓c✓ct✓t✓t✓ti✓i✓i✓io✓o✓o✓on✓n✓n✓n. Return true if each element of the
receiver collection is equal to the
corresponding element in the argument offset
by the amount given in the second argument.
findFirst: Find the key for the first element whose
value satisfies the argument block. Produce
an error message if no such element exists.
findFirst:ifAbsent:
Both arguments must be blocks. Find the key
for the first element whose value satisfies
the first argument block. If no such element
exists return the value of the second argu-
ment.
findLast: Find the key for the last element whose value
satisfies the argument block. Produce an
error message if no such element exists.
findLast:ifAbsent:
Both arguments must be blocks. Find the key
for the last element whose value satisfies
the first argument block. If no such element
exists return the value of the second
class S✓S✓S✓Se✓e✓e✓eq✓q✓q✓qu✓u✓u✓ue✓e✓e✓en✓n✓n✓nc✓c✓c✓ce✓e✓e✓ea✓a✓a✓ab✓b✓b✓bl✓l✓l✓le✓e✓e✓eC✓C✓C✓Co✓o✓o✓ol✓l✓l✓ll✓l✓l✓le✓e✓e✓ec✓c✓c✓ct✓t✓t✓ti✓i✓i✓io✓o✓o✓on✓n✓n✓n (continued)
argument block.
firstKey Return the first key valid for the receiver
collection.
indexOfSubCollection:startingAt:
Starting at the position given by the second
argument, find the next block of elements in
the receiver collection which match the col-
lection given by the first argument, and
return the index for the start of that block.
Produce an error message if no such position
exists.
indexOfSubCollection:startingAt:ifAbsent:
Similar to _✓i_✓n_✓d_✓e_✓x_✓O_✓f_✓S_✓u_✓b_✓C_✓o_✓l_✓l_✓e_✓c_✓t_✓i_✓o_✓n:_✓s_✓t_✓a_✓r_✓t_✓i_✓n_✓g_✓A_✓t:,
except that the result of the exception block
is produced if no position exists matching
the pattern.
last Return the last element in the receiver col-
lection.
lastKey Return the last key valid for the receiver
collection.
replaceFrom:to:with:
Replace the elements in the receiver collec-
tion in the positions indicated by the first
two arguments with values taken from the col-
lection given by the third argument.
replaceFrom:to:with:startingAt:
Replace the elements in the receiver collec-
tion in the positions indicated by the first
two arguments with values taken from the col-
lection given in the third argument, starting
at the position given by the fourth argument.
_✓n reversed Return a collection, like the receiver, with
elements reversed.
reverseDo: Similar to _✓d_✓o:, except that the items are
presented in reverse order.
_✓n sort Return a collection, like the receiver, with
the elements sorted using the comparison <=.
Elements must be able to respond to the
binary message <=.
_✓n sort: The argument must be a two argument block
which yields a boolean. Return a collection,
like the receiver, sorted using the argument
to compare elements for the purpose of
class S✓S✓S✓Se✓e✓e✓eq✓q✓q✓qu✓u✓u✓ue✓e✓e✓en✓n✓n✓nc✓c✓c✓ce✓e✓e✓ea✓a✓a✓ab✓b✓b✓bl✓l✓l✓le✓e✓e✓eC✓C✓C✓Co✓o✓o✓ol✓l✓l✓ll✓l✓l✓le✓e✓e✓ec✓c✓c✓ct✓t✓t✓ti✓i✓i✓io✓o✓o✓on✓n✓n✓n (continued)
ordering.
with:do: The second argument must be a two argument
The class A✓A✓A✓Ar✓r✓r✓rr✓r✓r✓ra✓a✓a✓ay✓y✓y✓ye✓e✓e✓ed✓d✓d✓dC✓C✓C✓Co✓o✓o✓ol✓l✓l✓ll✓l✓l✓le✓e✓e✓ec✓c✓c✓ct✓t✓t✓ti✓i✓i✓io✓o✓o✓on✓n✓n✓n provides protocol for col-
lections with a Fixed size and integer keys. Unlike other
collections, which are created using the message _✓n_✓e_✓w,
instances of A✓A✓A✓Ar✓r✓r✓rr✓r✓r✓ra✓a✓a✓ay✓y✓y✓ye✓e✓e✓ed✓d✓d✓dC✓C✓C✓Co✓o✓o✓ol✓l✓l✓ll✓l✓l✓le✓e✓e✓ec✓c✓c✓ct✓t✓t✓ti✓i✓i✓io✓o✓o✓on✓n✓n✓n must be created using the one
argument message _✓n_✓e_✓w:. The argument given with this message
must be a positive integer, representing the size of the
collection to be created. In addition to the protocol
shown, many of the methods inherited from superclasses are
redefined in this class.
_✓R_✓e_✓s_✓p_✓o_✓n_✓d_✓s _✓t_✓o
= The argument must also be an A✓A✓A✓Ar✓r✓r✓rr✓r✓r✓ra✓a✓a✓ay✓y✓y✓y. Test
whether the receiver and the argument have
equal elements listed in the same order.
at:ifAbsent: Return the element stored with the given key.
Return the result of evaluating the second
argument if the key is not valid for the
receiver collection.
_✓n padTo: Return an array like the received that is at
least as long as the argument value. Returns
the receiver if it is already longer than the
argument.
_✓E_✓x_✓a_✓m_✓p_✓l_✓e_✓s
Printed result
'small' = 'small' True
'small' = 'SMALL' False
'small' asArray #( $s $m $a $l $l)
'small' asArray = 'small' True
#(1 2 3) padTo: 5 #(1 2 3 nil nil)
#(1 2 3) padTo: 2 #(1 2 3)
Object
Collection
KeyedCollection
SequenceableCollection
ArrayedCollection
A✓A✓A✓Ar✓r✓r✓rr✓r✓r✓ra✓a✓a✓ay✓y✓y✓y
Instances of the class A✓A✓A✓Ar✓r✓r✓rr✓r✓r✓ra✓a✓a✓ay✓y✓y✓y are perhaps the most com-
monly used data structure in Smalltalk programs. A✓A✓A✓Ar✓r✓r✓rr✓r✓r✓ra✓a✓a✓ay✓y✓y✓ys✓s✓s✓s are
represented textually by a pound sign preceding the list of
array elements.
_✓R_✓e_✓s_✓p_✓o_✓n_✓d_✓s _✓t_✓o
at: Return the item stored in the position given
by the argument. An error message is pro-
duced, and n✓n✓n✓ni✓i✓i✓il✓l✓l✓l returned, if the argument is
not a valid key.
at:put: Store the second argument in the position
given by the first argument. An error mes-
sage is produced, and n✓n✓n✓ni✓i✓i✓il✓l✓l✓l returned, if the
argument is not a valid key.
grow: Return a new array one element larger than
the receiver, with the argument value
attached to the end. This is a slightly more
efficient command than _✓c_✓o_✓p_✓y_✓W_✓i_✓t_✓h:, although
the effect is the same.
_✓E_✓x_✓a_✓m_✓p_✓l_✓e_✓s
Printed result
i <- #(110 101 97)
i size 3
i <- i grow: 116 #( 110 101 97 116)
i <- i collect: [:x | x asCharacter] #( #n #e #a #t )